using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using EIMS.Models.Enums;

namespace EIMS.Models
{
    /// <summary>
    /// 供应商交易记录
    /// </summary>
    public class SupplierTransaction
    {
        public int Id { get; set; }

        [Required(ErrorMessage = "交易编号不能为空")]
        [Display(Name = "交易编号")]
        [StringLength(50, ErrorMessage = "交易编号不能超过50个字符")]
        public string TransactionNumber { get; set; }

        [Display(Name = "交易类型")]
        public TransactionType TransactionType { get; set; }
        
        [Display(Name = "支付方式")]
        public PaymentMethod PaymentMethod { get; set; }

        [Required(ErrorMessage = "交易日期不能为空")]
        [Display(Name = "交易日期")]
        [DataType(DataType.Date)]
        public DateTime TransactionDate { get; set; }

        [Required(ErrorMessage = "交易金额不能为空")]
        [Display(Name = "交易金额")]
        [Range(0.01, double.MaxValue, ErrorMessage = "交易金额必须大于0")]
        [Column(TypeName = "decimal(18, 2)")]
        public decimal Amount { get; set; }

        [Display(Name = "付款状态")]
        public PaymentStatus PaymentStatus { get; set; }

        [Display(Name = "付款日期")]
        [DataType(DataType.Date)]
        public DateTime? PaymentDate { get; set; }

        [Display(Name = "订单关联")]
        public int? OrderId { get; set; }
        
        [Display(Name = "交易说明")]
        [StringLength(500, ErrorMessage = "交易说明不能超过500个字符")]
        public string Description { get; set; }

        [Display(Name = "备注")]
        [StringLength(500, ErrorMessage = "备注不能超过500个字符")]
        public string Remarks { get; set; }

        [Display(Name = "创建时间")]
        public DateTime CreatedAt { get; set; }
        
        [Display(Name = "更新时间")]
        public DateTime? UpdatedAt { get; set; }

        [Display(Name = "创建人")]
        [StringLength(50, ErrorMessage = "创建人不能超过50个字符")]
        public string CreatedBy { get; set; }

        // 外键关联
        [Display(Name = "所属供应商")]
        [Required(ErrorMessage = "所属供应商不能为空")]
        public int SupplierId { get; set; }

        [ForeignKey("SupplierId")]
        public Supplier Supplier { get; set; }
    }
} 